<html xmlns:th="http://www.thymeleaf.org">
<head>
    <!--资源获取-->
    <base th:href="|${#request.getContextPath()}/|">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="static/lib/html5shiv.js"></script>
    <script type="text/javascript" src="static/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="static/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="static/lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <!--layui-->
    <link rel="stylesheet" type="text/css" href="static/layui/css/layui.css"/>
    <script type="text/javascript" src="static/layui/layui.js"></script>
    <title>资讯列表</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
    首页
    <span class="c-gray en">&gt;</span>
    admin
    <span class="c-gray en">&gt;</span>
    投资管理
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
       href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    <!--收藏-->
    <a id="djsc" class="btn btn-success radius r " style="line-height:1.6em;margin-top:3px" href="javascript:;"
       title="收藏">
        <i id="sc" class="layui-icon"></i>
    </a>
    <!--收藏-->
</nav>
<fieldset class="layui-elem-field layui-field-title">
    <legend>投资管理</legend>
</fieldset>

<form class="layui-form layui-row layui-col-space10" action="">
    <div class=" layui-col-xs5">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-block">
            <input type="text" id="lx" name="title" lay-verify="title" autocomplete="off" placeholder="请输入类型"
                   class="layui-input">
        </div>
    </div>
    <div class=" layui-col-xs5">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" id="totle" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题"
                   class="layui-input">
        </div>
    </div>

    <div class=" layui-col-xs2">

        <button class="layui-btn" lay-submit lay-filter="formDemo">确定</button>
    </div>
</form>
<table class="layui-hide" id="demo" lay-filter="test"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script type="text/javascript" src="static/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="static/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="static/my/js/post.js"></script>
<script type="text/javascript" src="static/my/js/util.js"></script>
<script>
    var dates;

    /*收藏按钮*/
    var ejhref = "Investment/adminHtml";//收藏路径
    var ejhrefname = "投资管理"
    ccscym(ejhref)
    $("#djsc").on("click", function () {
        scym(ejhref, ejhrefname)
    })
    /*收藏按钮*/


    layui.use(['layer', 'laydate','form'], function () {
        //得到各种内置组件
        var table = layui.table,
        form =layui.form; //表格

        //执行一个 table 实例
        table.render({
            elem: '#demo'
            ,id :"table1"
            , url: '/Investment/selectTimelxs' //数据接口
            , title: '赛道类型表'
            , page: true //开启分页
            , defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '删除'
                ,layEvent: 'del'
                ,icon: 'layui-icon-delete'
            }, { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可update
                title: '添加'
                ,layEvent: 'add'
                ,icon: 'layui-icon-add-1'
            },{ //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可update
                title: '编辑'
                ,layEvent: 'update'
                ,icon: 'layui-icon-edit'
            },'filter', 'exports', 'print']
            , toolbar: true  //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
            , cols: [
                [ //表头
                    {type: 'checkbox', field: 'uId', fixed: 'left'}
                    , {field: 'timeLb', title: 'ID', sort: true, fixed: 'left'}
                    , {field: 'lx', title: '类型', sort: true}
                    , {field: 'totle', title: '标题', sort: true}
                    , {field: 'remarks', title: '备注', sort: true}
                    , {field: 'initial', title: '初始金钱', sort: true}
                    , {field: 'continuousTime', title: '天数', sort: true}
                    , {field: 'jie', title: '届数'}
                    , {field: 'cron', title: '周期', sort: true, templet: function (d) {
                        var ad = "未设置周期";
                        if (d.cron != null && d.cron != "") {
                            ad = d.cron
                        }
                        return ad;
                    }}
                    ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}

                ]
            ]
        });
        //头工具栏事件
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id)
                , data = checkStatus.data; //获取选中的数据

            var lx =$("#lx").val(),
                totle = $("#totle").val();
            switch(obj.event){
                //自定义头工具栏右侧图标 - 提示
                case 'del':
                    if (data.length === 0) {
                        layer.msg('请选择一行');
                    } else {
                        var s = new Array();
                        for (var aa of data) {
                            s.push(aa.uId)
                        }
                        $.ajax({
                            url: "Investment/deletetzsd",
                            type: "DELETE",
                            data: {
                                "timeLbs": s
                            }, success: function () {
                                layer.msg('删除成功');
                            }
                        });
                        table.reload("table1", {
                            where: {
                                "totle": totle,
                                "lx": lx
                            }
                        });
                    }
                    break;
                case 'add':
                    layer.open({
                        type: 2,
                        area: ['60%', '80%'],
                        fixed: false, //不固定
                        maxmin: true,
                        content: 'Investment/adminIUtimetz'
                    })
                    break;
                case 'update':
                    if (data.length === 0) {
                        layer.msg('请选择一行');
                    } else if (data.length > 1) {
                        layer.msg('只能同时编辑一个');
                    } else {
                        layer.open({
                            type: 2,
                            area: ['60%', '80%'],
                            fixed: false, //不固定
                            maxmin: true,
                            content: 'Investment/adminIUtimetz?timeLb=' + data[0].timeLb
                        })
                        table.reload("table1", {
                            where: {
                                "totle": totle,
                                "lx": lx
                            }
                        });
                    }
                    break;
            };
        });
        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                   $.ajax({
                        url: "Investment/deletetzsd",
                        type: "Post",
                        data: {
                            "timeLb": data.timeLb
                        },
                        success: function (regas) {
                            layer.close(index);
                        }
                    })
                });
            } else if(obj.event === 'detail'){
                console.log(data)
                layer.open({
                    type: 2,
                    area: ['90%', '90%'],
                    fixed: false, //不固定
                    maxmin: true,
                    content: 'Investment/selectzq?timeLb=' + data.timeLb
                })
            }
        });

        //监听提交
        form.on('submit(formDemo)', function(data){
            var lx =$("#lx").val(),
                totle = $("#totle").val();
            table.reload("table1",{where: {
                    "totle": totle,
                    "lx": lx
                }});
            return false;
        });
    })


</script>

<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/lib/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="static/lib/datatables/1.10.15/jquery.dataTables.min.js"></script>
<script type="text/javascript">


</script>

</body>
</html>
